<?php
header ( "Content-Type: text/html; charset=UTF-8" );
mb_internal_encoding ( "UTF-8" );


include './HeaderFile.class.php';
$genPath = 'F:\360yunpan\www\git.oschina.net\aliyun-openapi-cpp-sdk-generator';

function getProductDirArr($path){
	$prodArr=null;
	if ($handle = opendir($path)) { 
		while (false !== ($file = readdir($handle))) { 
			if ($file != "." && $file != "..") { 
				$fileobj = $path."/".$file;
				if (is_dir($fileobj)) { //dir
					$rawName = substr($file,strlen('aliyun-api-metadata-'));
					$prodArr[$file] = makeProdClassName($rawName);
				} else { //file
				} 
			} 
		} 
		closedir($handle);
	}
	return $prodArr;
}
function makeProdClassName($str){
	$str = str_replace('_', '-', $str);
	$arr = explode('-',$str);
	$name=null;
	foreach($arr as $val){
		$name.=ucwords($val);
	}
	return $name;
}

function getProductNameArr($arr){
	foreach($arr as $k=>$v){
		$arr[$k] = substr($v,strlen('aliyun-api-metadata-'));
	}
	return $arr;
}

function file_list($path, &$alljson){ 
	if ($handle = opendir($path)) { 
		while (false !== ($file = readdir($handle))) { 
			if ($file != "." && $file != "..") { 
				$fileobj=$path.'\\'.$file;
				
				if (is_dir($fileobj)) { //dir
					// $list[]= $fileobj;//去掉此行显示的是所有的非目录文件 
					// file_list($fileobj,$alljson); 
					$alljson[] = $fileobj;
				} else { //file
					// return basename($fileobj);
					if(basename($fileobj)!='Version-Info.json'){
						$alljson[] = $fileobj;
					}
				} 
			} 
		} 
		closedir($handle);
	}
} 

// $prodArr = getProductDirArr($path);
// $nameArr = getProductNameArr($prodArr);

// echo '<pre>';
// print_r( $prodArr );
// echo '</pre>';

$headerFile = new HeaderFile();
$path = 'F:\360yunpan\www\github.com\openapi-meta\api-metadata';
$prodPathArr = $headerFile->getProdPath ( $path );
//print_r ( $prodPathArr );
$arr = $headerFile->genFiles ( $prodPathArr );

print_r ( $arr );


?>


